Page({
  data: {
    goodsInfo: {},
    categoryText: ''
  },

  onLoad(options) {
    // 获取商品ID
    const goodsId = options.id;
    // 模拟从数据源获取商品详情（实际项目中应从接口请求）
    this.getGoodsDetail(goodsId);
  },

  // 获取商品详情
  getGoodsDetail(id) {
    // 模拟商品数据（实际项目中替换为接口请求）
    const goodsList = [
      {
        id: 1,
        name: '时尚休闲牛仔裤',
        price: 129.9,
        sales: 125,
        category: 1,
        desc: '精选优质面料，舒适透气，时尚百搭，多尺码可选',
        image: "https://picsum.photos/seed/tshirt1/300/300",
        imageList: [
          'https://picsum.photos/seed/sweater1/300/300',
          'https://picsum.photos/seed/shoes1/300/300',
          "https://picsum.photos/seed/jeans1/300/300"
        ]
      },
      {
        id: 2,
        name: '夏季纯棉T恤',
        price: 59.9,
        sales: 342,
        category: 2,
        desc: '100%纯棉材质，柔软亲肤，多种颜色可选，夏季必备',
        image: "https://picsum.photos/seed/tshirt1/300/300",
        imageList: [
          'https://picsum.photos/seed/shoes1/300/300',
          "https://picsum.photos/seed/jeans1/300/300",
          'https://picsum.photos/seed/sweater1/300/300',
        ]
      },
      {
        id: 3,
        name: '运动休闲鞋',
        price: 239,
        sales: 89,
        category: 1,
        desc: '轻便舒适，防滑鞋底，适合日常运动和休闲穿着',
        image: "https://picsum.photos/seed/tshirt1/300/300",
        imageList: [
          'https://picsum.photos/seed/sweater1/300/300',
          'https://picsum.photos/seed/shoes1/300/300',
          "https://picsum.photos/seed/jeans1/300/300",
        ]
      },
      {
        id: 4,
        name: '商务正装衬衫',
        price: 159,
        sales: 67,
        category: 1,
        desc: '免烫处理，抗皱有型，适合商务场合穿着',
        image: "https://picsum.photos/seed/sweater1/300/300",
        imageList: [
          'https://picsum.photos/seed/sweater1/300/300',
          'https://picsum.photos/seed/shoes1/300/300',
          "https://picsum.photos/seed/jeans1/300/300"
        ]
      },
    ];

    const goodsInfo = goodsList.find(item => item.id === parseInt(id));
    const categoryText = goodsInfo.category === 1 ? '新款商品' : '活动商品';
    
    this.setData({
      goodsInfo,
      categoryText
    });
  }
})